<template>
	<view class="alinitem">
		<picker mode="multiSelector" @change="bindMultiPickerChange" @columnchange="bindMultiPickerColumnChange" :value="multiIndex_1"
		 :range="multiArray_1">
			<view class="itemLeft dis dis2 dis7  " v-if="city==''">请选择</view>
			<view class="itemLeft dis dis2 dis7 name_1_2_12" v-if="city !=''">{{city}}</view>
		</picker>
	</view>
</template>

<script>
	export default {
		props: ['multiIndex', 'multiArray', 'objectMultiArray1','index','city_s'],
		data() {
			return {
				multiIndex_1: this.multiIndex,//获取的下标
				multiArray_1: this.multiArray,//数据省份 objectMultiArray1市
				city: this.city_s,//地址
			};

		},
		methods: {
			bindMultiPickerChange(e) {
				console.log(e)
				this.multiIndex_1[0] = e.detail.value[0];
				this.multiIndex_1[1] = e.detail.value[1];
				let city = this.multiArray_1[1][this.multiIndex_1[1]]
				let birthprovince = this.multiArray_1[0][this.multiIndex_1[0]];
				this.city = city;
				console.log(this.birthprovince, '----', this.city)
				let obj={
					city:city,
					province:birthprovince
				}
				console.log('index',this.index)
				if(this.index==1){
					this.$emit('fnnc', obj);
				}else{
					this.$emit('fnncs', obj);
				}
				
			},
			bindMultiPickerColumnChange(e) {
				let that = this;
				let list1 = [];
				// console.log(that.objectMultiArray1)
				// console.log(e)
				switch (e.detail.column) {
					case 0:
						for (var i = 0; i < that.objectMultiArray1.length; i++) {
							if (that.objectMultiArray1[i].parid == that.objectMultiArray1[e.detail.value].regid) {
								list1.push(that.objectMultiArray1[i].regname)
							}
						}
						// console.log(list)
						that.multiArray_1[1] = list1;
						that.multiIndex_1[0] = e.detail.value;
						that.multiIndex_1[1] = 0;
						this.$forceUpdate()
				}
				// console.log(this.province,'----',this.city1)
			},
		}
	}
</script>

<style lang="scss">
	@import "../common/css/flex.css";
	@import "../common/css/index.scss";
	.alinitem {
		width: 120upx;
		height: 80%;

		// border: 1px solid red;
		picker,
		.itemLeft {
			width: 100%;
			height: 80upx;
			font-size: 30upx;
			font-family: $typeface1;
			font-weight: 400;
			color: #6E9DFF;
		}

		.name_1_2_12 {
			color: #999999;
		}
	}
</style>
